package com.zhanglingfei.yuekaoshop.entity;

import lombok.Data;

import java.io.Serializable;

import javax.persistence.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @author Shichao.Lu
 * spu表，该表描述的是一个抽象性的商品，比如 iphone8
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@Entity
@Table(name = "tb_spu")
@DynamicInsert
@DynamicUpdate
public class Spu implements Serializable {

	/**
	 * spu id
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id")
	private Long id;

	@OneToOne
	@JoinColumn(name="id",referencedColumnName = "spuId",insertable = false,updatable = false)
	private SpuDetail spuDetail;

	/**
	 * 标题
	 */
	@Column(name = "title")
	private String title;

	/**
	 * 子标题
	 */
	@Column(name = "sub_title")
	private String subTitle;

	/**
	 * 1级类目id
	 */
	@Column(name = "cid1")
	private Long cid1;

	/**
	 * 2级类目id
	 */
	@Column(name = "cid2")
	private Long cid2;

	/**
	 * 3级类目id
	 */
	@Column(name = "cid3")
	private Long cid3;

	/**
	 * 商品所属品牌id
	 */
	@Column(name = "brand_id")
	private Long brandId;

	/**
	 * 是否上架，0下架，1上架
	 */
	@Column(name = "saleable")
	private Boolean saleable;

	/**
	 * 是否有效，0已删除，1有效
	 */
	@Column(name = "valid")
	private Boolean valid;

	/**
	 * 添加时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "create_time")
	private java.util.Date createTime;

	/**
	 * 最后修改时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "last_update_time")
	private java.util.Date lastUpdateTime;
}
